package top.gohigh.commonview;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;


public class GHPicturePreviewDialog extends Dialog {

    private TextView dialogTitle;
    private ImageView dialogImageView;
    private Button dialogConfirm;
    private Button dialogCancel;

    private String title,confirmText="确认",cancelText="取消";
    private Bitmap img;


    private View.OnClickListener confirmListener;
    private View.OnClickListener cancelListener;

    public GHPicturePreviewDialog(@NonNull Context context) {
        super(context, R.style.GHPicturePreviewDialog);
    }

    public GHPicturePreviewDialog(Context context, String title, Bitmap bitmap){
        super(context, R.style.GHPicturePreviewDialog);
        img=bitmap;
        this.title=title;
    }
    public GHPicturePreviewDialog(Context context, String title,String confirmText,String cancelText, Bitmap bitmap){
        super(context, R.style.GHPicturePreviewDialog);
        img=bitmap;
        this.title=title;
        this.confirmText=confirmText;
        this.cancelText=cancelText;
    }


    public void setOnConfirmListener(View.OnClickListener confirmListener){
        this.confirmListener=confirmListener;

    }
    public void setOnCancelListener(View.OnClickListener cancelListener){
        this.cancelListener=cancelListener;

    }



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_preview_image);
        dialogTitle=(TextView)findViewById(R.id.dialog_title);
        dialogImageView =(ImageView)findViewById(R.id.image);
        dialogConfirm=(Button)findViewById(R.id.dialog_confirm);
        dialogCancel=(Button)findViewById(R.id.dialog_cancel);

        dialogTitle.setText(title);
        dialogImageView.setImageBitmap(img);
        setCanceledOnTouchOutside(false);
        dialogConfirm.setOnClickListener(confirmListener);
        dialogCancel.setOnClickListener(cancelListener);

        dialogConfirm.setText(confirmText);
        dialogCancel.setText(cancelText);
    }


}
